package org.myorg.v5;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
public class test {
	public static void print(List<Integer> list) {
        Iterator<Integer> itr = list.iterator();
        while (itr.hasNext()) {
            System.out.print(itr.next());
            System.out.print(", ");
        }
        System.out.println("end");
    }

    public static void main(String[] args) {
        List<Integer> s = new ArrayList<Integer>();
        for (Integer i = 0; i < 10; i++) {
            s.add(i);
        }
        print(s);
        
        Iterator<Integer> itr = s.iterator();
        while (itr.hasNext()) {
            Integer i = itr.next();
            System.out.println("will del " + i);
            //if (i % 3 == 0) {
                itr.remove();
            //}
        }
        print(s);
    }
	
	/*public static void main(String[] arg) {
		/*double x = Double.MAX_VALUE;
		x = x+100;

		String str = "abcde";
		String str2 = "12345";
		int cp1 = 0, cp2 = 5; 
		String subs = str.substring(0,cp1) + str2.substring(cp1,cp2) + str.substring(cp2);
		System.out.println(x + " test " + subs);
		int a[][] = {{1,2},{3,4,5,6},{7,8,9}} ;

		for(int i=0 ; i <a.length ; i++) {
			for(int j=0 ; j<a[i].length ; j++) {
				System.out.println("a[" + i + "][" + j + "]=" + a[i][j]) ;
			}
		}

		double x1 = 100;
		x1 = Math.pow(x1, 1d/2d);
		System.out.println(x1);

		String str1 = new String("abcde");
		String str2 = new String("abcde");
		String str3 = new String("abcde");
		String str4 = new String("abcde");
		String str5 = new String("abcde");
		List list = new ArrayList();
		list.add(str1);
		list.add(str2);
		list.add(str3);
		list.add(str4);
		list.add(str5);
		System.out.println("list.size()=" + list.size());
		for (int i = 0; i < list.size(); i++) {
			if (((String) list.get(i)).startsWith("abcde")) {
				list.remove(i);
			}
		}
		System.out.println("after remove:list.size()=" + list.size());

		
		
		
		
		
		
		
		
		
		ArrayList<Integer> ma = new ArrayList<Integer>();
		for (int i = 0; i < 10; i++) {
			ma.add(i);
		}
		ListIterator mi = ma.listIterator();
		while (mi.hasNext()) {
			System.out.println(mi.next());
		}

		mi = ma.listIterator();
		while(mi.hasNext()) {
			//Iterator tm = (Iterator) mi.h;
			ListIterator tm = (ListIterator) mi.next();
			System.out.println("the value is " + mi.getClass());
			mi.remove();


			//mi.r
			mi = tm;

		}
		System.out.println("ma.size is " + ma.size());
		mi = ma.listIterator();
		while (mi.hasNext()) {
			System.out.println(mi.next());
		}


	}*/

}
